package com.sdap2.vo;

import com.sdap2.entity.SysRole;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

@Data
public class UserVO {
    private Long id;
    private String username;
    private String realName;
    private String phone;
    private Integer status;
    private List<String> roles;
    
    public static UserVO fromEntity(com.sdap2.entity.SysUser user) {
        if (user == null) {
            return null;
        }
        
        UserVO vo = new UserVO();
        vo.setId(user.getId());
        vo.setUsername(user.getUsername());
        vo.setRealName(user.getRealName());
        vo.setPhone(user.getPhone());
        vo.setStatus(user.getStatus());
        vo.setRoles(user.getRoles().stream()
                .map(SysRole::getRoleCode)
                .collect(Collectors.toList()));
        return vo;
    }
} 